from time import sleep

import pytest
from appium.webdriver.common.appiumby import AppiumBy

from base.wework_app import WorkPage



class ManualPage(WorkPage):
    _name = AppiumBy.XPATH, '//*[@text="姓名"]/../*[@text="必填"]'
    _id = AppiumBy.XPATH, '//*[@text="账号"]/../*[@text="选填"]'
    _phone = AppiumBy.XPATH, '//*[@text="手机号"]'
    _email = AppiumBy.XPATH, '//*[@text="企业邮箱"]/../*[@text="必填"]'
    _not_put = AppiumBy.XPATH, '//*[@text="保存后自动发送邀请通知"]'
    _save = AppiumBy.XPATH, '//*[@text="保存"]'

    def wework_add(self, myname, myid, email, phone):
        # 输入姓名
        self.find_ele_key(self._name, myname)
        # 输入账号
        self.find_ele_key(self._id, myid)
        # 输入手机
        self.find_ele_key(self._phone, phone)
        # 输入邮箱
        self.find_ele_key(self._email, email)
        # 执行滑动操作
        self.find_swipe('保存后自动发送邀请通知', '0.9', '0.1')
        # 点击不发送通知
        self.find_ele_click(self._not_put)
        # 点击保存
        self.find_ele_click(self._save)
        sleep(1)
        from page.add_page import AddPage
        return AddPage(self.driver)
